

import java.util.ArrayList;
import java.util.HashSet;

public class RegexScanner {
	ArrayList<StringList> stringlists;

	public RegexScanner(String filename, String regex) {
		stringlist_parser parser = new stringlist_parser();
		parser.stringlist_regExMain(regex);
		Nfa nfa = new Nfa(parser.nfaMap, parser.nfaColumns,
				parser.characterClasses);
		HashSet<Integer> acceptStates = new HashSet<Integer>();
		for (IdClass c : parser.idClasses) {
			for (int i : c.getAcceptStates()) {
				acceptStates.add(i);
			}
		}
		NFAtoDFA nfa_to_dfa = new NFAtoDFA(nfa.getNfa(), acceptStates);
		Stringlist_TableWalker tablewalker = new Stringlist_TableWalker(
				filename, nfa_to_dfa.getDFA(), parser.characterClasses,
				parser.idClasses, acceptStates);
		stringlists = tablewalker.Stringlist_getTokensList();
	}

	public ArrayList<StringList> getStringlists() {
		return stringlists;
	}
}
